// ----------------------------------------------------------------------------
/**
 * @file    main.cpp
 *
 * @brief   The main ChatServer class
 *
 *
 *
 * @author  Siddharth Sathyam <ssathy2@gmail.com>
 * @author  Alan Ruvalcaba <aruval3@gmail.com>
 * @author  Patrick LaMontagna <plamontagna@gmail.com
 *
 * @version 1.0
 *
 * @date    November 24th, 2011
 *
 */
// ----------------------------------------------------------------------------

#include <QtCore/QCoreApplication>
#include <QTime>
#include <QDebug>
#include <QTextStream>
#include <iostream>
#include "server.h"

/**
 * @class   main
 *
 * @brief   The main.cpp for the ChatServer
 *
 */

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QTime clock; /*!< Detailed description after the member */

    Server* centralServer = new Server();
    QTextStream readIn(stdin);

    qDebug() << "Enter the Server address wanted: ";
    QString serverAddr;
    readIn >> serverAddr;

    QHostAddress addr = QHostAddress(serverAddr);
    if(centralServer->startServer(addr, 1234))
    {
	qDebug() << clock.currentTime().toString(Qt::TextDate) << ": Server Started at - " << centralServer->serverAddress().toString() << ":" << centralServer->serverPort();
    }
    else
    {
	qDebug() << clock.currentTime().toString(Qt::TextDate) << ": Problem starting server - " << centralServer->errorString();
    }

    return a.exec();
}
